/**
 * Copyright (c) 2017-2024 Nop Platform. All rights reserved.
 * Author: canonical_entropy@163.com
 * Blog:   https://www.zhihu.com/people/canonical-entropy
 * Gitee:  https://gitee.com/canonical-entropy/nop-entropy
 * Github: https://github.com/entropy-cloud/nop-entropy
 */
package com.gitee.wsl.struct.table.impl

import com.gitee.wsl.api.IFreezable
import com.gitee.wsl.struct.table.ICell
import com.gitee.wsl.struct.table.IRow
import com.gitee.wsl.struct.table.IRowView


class ProxyCell(val cell: ICell) : ICell {
    /**
     * 合并单元格所对应的左上角的单元格
     */

    //private var frozen = false



    override var row: IRowView? = null
        set(row) {
            checkAllowChange()
            field = row
        }

    override var isFrozen: Boolean = false

    /**
     * 从真实单元格到本单元格的行的偏移量，从0开始
     */
    override var rowOffset = 0

    /**
     * 从真实单元格到本单元格的列的偏移量，从0开始
     */
    override var colOffset = 0

    constructor(cell: ICell, rowOffset: Int, colOffset: Int) : this(cell) {
        this.rowOffset=rowOffset
        this.colOffset=colOffset
    }

    override fun toString(): String {
        return (("ProxyCell[rowOffset=" + rowOffset + ",colOffset=" + colOffset + ",rowSpan=" + this.rowSpan) + ","
                + "colSpan=" + this.colSpan).toString() + "]"
    }

    override fun cloneInstance(): ProxyCell {
        throw UnsupportedOperationException("ProxyCell.cloneInstance")
    }

    override val styleId: String?
        get() = null

    /*fun getRowOffset(): Int {
        return rowOffset
    }


    fun getColOffset(): Int {
        return colOffset
    }*/

    override val isProxyCell: Boolean
        get() = true

    override val isBlankCell: Boolean
        get() = true

    override val realCell: ICell
        get() = cell

    override var mergeAcross: Int
        get() = 0
        set(mergeAcross) {
            throw UnsupportedOperationException()
        }

    override var mergeDown: Int
        get() = 0
        set(mergeDown) {
            throw UnsupportedOperationException()
        }

    override var value: Any?
        get() = null
        set(value) {
            throw UnsupportedOperationException()
        }

    override var comment: String?
        get() = null
        set(comment) {
        }

    override val formula: String?
        get() = null

    override val id: String?
        get() = null

    /*fun prop_get(propName: String?): Any? {
        return null
    }

    fun prop_has(propName: String?): Boolean {
        return false
    }

    fun prop_set(propName: String?, value: Any?) {
        throw UnsupportedOperationException()
    }*/
}